package com.gxa.modules.service.impl;

import com.gxa.common.vo.JsonResult;
import com.gxa.modules.mapper.AccountMapper;

import com.gxa.modules.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AccountServiceImpl implements AccountService {
    @Autowired(required = false)
    private AccountMapper accountMapper;

    @Override
    public JsonResult queryAccount(Integer page, Integer limit) {
        JsonResult r=new JsonResult();
        Integer parma1=(page-1)*limit;
        Integer parma2=limit;
        List<Map> accountList = accountMapper.queryAccount(parma1,parma2);
        Integer count=accountMapper.findCount();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setCount(count);
        r.setData(accountList);
        return r;
    }

    @Override
    public JsonResult searchAccount(Integer account_number) {
        JsonResult r=new JsonResult();
        r.setCode(200);
        r.setMsg("查询成功");
        Map account =accountMapper.searchAccount(account_number);
        r.setData(account);
        return r;
    }

    @Override
    public JsonResult queryTodayAccount(Integer currentPage, Integer pageSize) {
        JsonResult r=new JsonResult();
        Integer parma1=(currentPage-1)*pageSize;
        Integer parma2=pageSize;
        List<Map> todayAccountList = accountMapper.queryTodayAccount(parma1,parma2);
        Integer count=accountMapper.queryTodayAccountCount();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setCount(count);
        r.setData(todayAccountList);
        return r;
    }

    @Override
    public JsonResult queryYesterdayAccount(Integer currentPage, Integer pageSize) {
        JsonResult r=new JsonResult();
        Integer parma1=(currentPage-1)*pageSize;
        Integer parma2=pageSize;
        List<Map> yesterdayAccount = accountMapper.queryYesterdayAccount(parma1,parma2);
        Integer count=accountMapper.queryYesterdayAccountCount();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setCount(count);
        r.setData(yesterdayAccount);
        return r;
    }

    @Override
    public JsonResult queryWeekAccount(Integer currentPage, Integer pageSize) {
        JsonResult r=new JsonResult();
        Integer parma1=(currentPage-1)*pageSize;
        Integer parma2=pageSize;
        List<Map> weekAccountList = accountMapper.queryWeekAccount(parma1,parma2);
        Integer count=accountMapper.queryWeekAccountCount();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setCount(count);
        r.setData(weekAccountList);
        return r;
    }

    @Override
    public JsonResult queryMonthAccount(Integer currentPage, Integer pageSize) {
        JsonResult r=new JsonResult();
        Integer parma1=(currentPage-1)*pageSize;
        Integer parma2=pageSize;
        List<Map> monthAccountList = accountMapper.queryMonthAccount(parma1,parma2);
        Integer count=accountMapper.queryMonthAccountCount();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setCount(count);
        r.setData(monthAccountList);
        return r;
    }

    @Override
    public JsonResult queryBetweenTimeAccount(Integer currentPage, Integer pageSize, String beforeTime, String afterTime) {
        JsonResult r=new JsonResult();
        Integer parma1=(currentPage-1)*pageSize;
        Integer parma2=pageSize;
        List<Map> betweenTimeList = accountMapper.queryBetweenTimeAccount(parma1,parma2,beforeTime,afterTime);
        Integer count=accountMapper.queryBetweenTimeAccountCount(beforeTime,afterTime);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setCount(count);
        r.setData(betweenTimeList);
        return r;
    }
}
